/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import com.zimbra.cs.redolog.TransactionId;
/*    */ import java.io.IOException;
/*    */ import java.util.Iterator;
/*    */ import java.util.LinkedHashSet;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class Checkpoint
/*    */   extends ControlOp
/*    */ {
/*    */   LinkedHashSet<TransactionId> mTxnSet;
/*    */   
/*    */   public Checkpoint()
/*    */   {
/* 46 */     super(MailboxOperation.Checkpoint);
/* 47 */     this.mTxnSet = new LinkedHashSet();
/*    */   }
/*    */   
/*    */   public Checkpoint(LinkedHashSet<TransactionId> txns) {
/* 51 */     super(MailboxOperation.Checkpoint);
/* 52 */     this.mTxnSet = txns;
/* 53 */     setTransactionId(new TransactionId());
/*    */   }
/*    */   
/*    */   public int getNumActiveTxns() {
/* 57 */     return this.mTxnSet.size();
/*    */   }
/*    */   
/*    */   public Set getActiveTxns() {
/* 61 */     return this.mTxnSet;
/*    */   }
/*    */   
/*    */ 
/*    */   public void log() {}
/*    */   
/*    */   protected String getPrintableData()
/*    */   {
/* 69 */     if (this.mTxnSet.size() > 0) {
/* 70 */       StringBuffer sb = new StringBuffer();
/* 71 */       sb.append(this.mTxnSet.size()).append(" active txns: ");
/* 72 */       int i = 0;
/* 73 */       for (Iterator it = this.mTxnSet.iterator(); it.hasNext(); i++) {
/* 74 */         TransactionId txn = (TransactionId)it.next();
/* 75 */         if (i > 0)
/* 76 */           sb.append(", ");
/* 77 */         sb.append(txn.toString());
/*    */       }
/* 79 */       return sb.toString();
/*    */     }
/* 81 */     return null;
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException {
/* 85 */     out.writeInt(this.mTxnSet.size());
/* 86 */     for (Iterator it = this.mTxnSet.iterator(); it.hasNext();) {
/* 87 */       TransactionId txn = (TransactionId)it.next();
/* 88 */       txn.serialize(out);
/*    */     }
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException {
/* 93 */     int num = in.readInt();
/* 94 */     for (int i = 0; i < num; i++) {
/* 95 */       TransactionId txn = new TransactionId();
/* 96 */       txn.deserialize(in);
/* 97 */       this.mTxnSet.add(txn);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/Checkpoint.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */